/* Sentinel - IRC Statistical and Operator Services
** stats.h - main header file
**
** Copyright W. Campbell and others.  See README for more details
** Some code Copyright: Jonathan George, Kai Seidler, ircd-hybrid Team,
**                      IRCnet IRCD developers.
**
** $Id: stats.h,v 1.83 2004/01/03 01:10:19 wcampbel Exp $
*/

#ifndef STATS_H
#define STATS_H

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include "setup.h"
#include "config.h"
#include "dlink.h"
#include "support.h"

#ifdef HAVE_LIBCRYPTO
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/bio.h>
#include <openssl/rand.h>
#include <openssl/err.h>
#endif

/* Standard settings... ONLY change these if you know what
** you are doing.  The service may fail to work if not
**
** NOTE:  These are used to get rid of "magic numbers" in the code
**
** NOTE:  NEVER Change BUFSIZE
*/
#define BUFSIZE			512
#define CONFIG_NAME		PREFIX "/etc/sentinel.cfg"
#define TLD_FILE		PREFIX "/data/tlds.nfo"
#define STATS_DB		PREFIX "/data/stats.db"
#define NSTATS_DB		PREFIX "/data/nstats.db"
#define PIDFILE			PREFIX "/etc/sentinel.pid"
#define LOGFILE			PREFIX "/logs/sentinel.log"
#define SPLITLOG		PREFIX "/logs/split.log"
#define IOLOGFILE		PREFIX "/logs/io.log"
#define SPYLOG			PREFIX "/logs/spy.log"
#define DRONELOG		PREFIX "/logs/drone.log"
#define BACKUPLOGFMT		PREFIX "/logs/sentinel-%m-%d.log"
#define BACKUPSPLOGFMT		PREFIX "/logs/split-%m-%d.log"
#define BACKUPSPYFMT		PREFIX "/logs/spy-%m-%d.log"
#define BACKUPDRONEFMT		PREFIX "/logs/drone-%m-%d.log"
#define BACKUPIOFMT		PREFIX "/logs/io-%m-%d.log"
#define TIMEFMT			"%H:%M[%m/%d/%Y]"

#define FTMFMT			"%A, %e %b %Y, %H:%M %Z"
#define IRCTFMT			"%A %B %d %Y -- %H:%M:%S "

#define MAXHOST			63
#define MAXPASS			32
#define MAXNICK			32
#define MAXUSER			10
#define MAXUSERHOST		(MAXUSER + MAXHOST + 2) 
/* Maximum length of a TLD, used to size the TLD struct */
#define MAXTLD			10
#define SJPARA			250 /* Maximum number of nicks */
#define LINE			80 /* Don't change this */
#define TIMEBUF			100 /* Accepts time formatting */ 
/* A tunable, the maximum number of nick collides permitted in COLLIDETIME */
#define MAXCOLLISIONS           20
#define STATSSAVETIME		120 /* The time between db syncs */
#define COLLIDETIME		60  /* see MAXCOLLISIONS */ 
/* The default delay before writing out the HTML dump, used to make sure
** the service is at least part way sync'ed to its uplink before
** generating statistics.
*/
#define HTMLDELAY		30 
/* The delay before writing out the data dump */
#define DUMPDELAY		30 
/* The time to wait between checks for auto-expiration of splits */
#define EXPIREPOLL		60 
/* The time to wait between pinging the uplink (needed on Linux to detect when
** the network connection has been severed
*/
#define PINGDELAY		60 
/* The number of seconds to delay sending spy() messages */
#define DEFAULT_DELAY		30 
/* The number of seconds to wait before sending CTCP VERSION's */
#define VERSION_DELAY		300 
/* The number of CTCP VERSION requests to send per run, after connecting to
** the server, after waiting for VERSION_DELAY seconds.
*/
#define VERSION_PERRUN		100
/* The number of second per run of pending CTCP VERSION requests */
#define VERSION_INTERVAL	20
/* The number of seconds to wait between checks if a SIGHUP was received */
#define REHASHINTERVAL		3 
/* The number of seconds to wait between midnight rollover checks */
#define MIDNIGHTINTERVAL	1 
/* The number of seconds between flushes of the log files */
#define LOGFLUSHTIME		10 
/* The maximum number of countries returned when StatServ COUNTRY is used. */
#define COUNTRY_LIMIT           10
#define CHANLEN                 200 /* Channel length from Hybrid */
#define KEYLEN                  24  /* Key length from Hybrid */
#define LIMITLEN		11  /* Enough to hold 2147483647 */
#define DEFAULT_CLONES_LIMIT    4   /* The default number of clones to report */

/* Hash table sizes must be prime */
#define S_TABLE_SIZE	97
#define U_TABLE_SIZE	1999
#define C_TABLE_SIZE	311

#define T_TABLE_SIZE		97
#define MSG_TABLE_SIZE		47
#define H_TABLE_SIZE		1999

/* How large should the token table be in 2.10 */
#define TOKEN_TABLE_SIZE	100

#define TRUE 1
#define FALSE 0

/* Define the default time delay (in milliseconds) */
#define DELAYTIME 750000

/* SplitServ defines */
#define MAXDEPTH 32

/* JupeServ defines */
#define OLDJUPEFILE PREFIX "/etc/jupes.cfg"
#define JUPEFILE    PREFIX "/etc/jupe.cfg" 
/* The time between jupe vote expiration checks */
#define JUPE_EXP_DELAY	60 
/* The time votes remain pending */
#define JUPE_EXP_TIME	7200

/* Additional Logfiles */
#define SPLIT_LOG	1
#define IO_LOGNO	2
#define DRONE_LOG	3
#define SPY_LOG		4

#endif
